package operation;
import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class ReturnOperation implements IOperation{
    public void work(BookList bookList){
        System.out.println("归还图书...");
        System.out.println("你想要归还的图书的名称是：");
        Scanner scanner=new Scanner(System.in);
        String bookName=scanner.nextLine();
        int currentSize=bookList.getUsedSize();
        for(int i=0;i<currentSize;i++){
            Book book=bookList.getBook(i);
            if(book.getName().equals(bookName)){
                book.setIslent(false);
                System.out.println("归还成功：");
                return;
            }
        }
        System.out.println("找不到这本书，归还失败:");
    }
}
